package com.sq.partner.manager.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.SaleConfigDao;
import com.sq.partner.manager.mybatis.model.SaleConfig;
import com.sq.partner.manager.service.SaleConfigService;
import com.sq.partner.manager.util.Page;


@Service(value = "saleConfigService")
public class SaleConfigServiceImpl implements SaleConfigService {
	@Resource
	private SaleConfigDao saleConfigDao;
	/***
	 * 查询下一个费用配置号
	 */
	@Override
	public String queryNextAgentNo(String agentType) throws Exception {
		return saleConfigDao.queryNextAgentNo(agentType);
	}
	@Override
	public boolean addSaleConfig(SaleConfig saleConfig) throws Exception {
		return saleConfigDao.addSaleConfig(saleConfig);
	}
	@Override
	public Page<Map<String, Object>> queryPageByCriteria(
			Page<Map<String, Object>> page) throws Exception {
		/**查询总条数*/
		Integer i=saleConfigDao.queryTotalByCriteria(page.getMap());
		page.setTotal(i);
		List<Map<String, Object>> sales=saleConfigDao.queryListByCriteria(page.getMap());
		page.setData(sales);
		return page;
	}
	@Override
	public boolean delSaleConfig(SaleConfig saleConfig) throws Exception {
		
		try {
			saleConfigDao.delSaleConfig(saleConfig);
		} catch (Exception e) {
			return false;
		}
		return true;
	}
	@Override
	public List<SaleConfig> searchSaleConfigsListByplanCode(
			Map<String, Object> maps) throws Exception {
		// TODO Auto-generated method stub
		return saleConfigDao.searchSaleConfigsListByplanCode(maps);
	}
	@Override
	public SaleConfig searchSaleConfigById(String agentNo) throws Exception {
		// TODO Auto-generated method stub
		return saleConfigDao.searchSaleConfigById(agentNo);
	}
	@Override
	public boolean updateSaleConfig(SaleConfig SaleConfig) throws Exception {
		return saleConfigDao.updateSaleConfig(SaleConfig);
	}
	public  List<Map<String, Object>> implSaleConfigs(
			Map<String, Object> maps) throws Exception{
		return saleConfigDao.implSaleConfigs(maps);
	} ;
}
